class ProductionSchedulesController < ApplicationController
  before_action :set_production_schedule, only: [:show, :edit, :update, :destroy]

  respond_to :html

  def index
    @production_schedules = ProductionSchedule.order(created_at: :desc).page(params[:page])
    respond_with(@production_schedules)
  end

  def show
    respond_with(@production_schedule)
  end

  def new
    @production_schedule = ProductionSchedule.new
    respond_with(@production_schedule)
  end

  def edit
  end

  def create
    @production_schedule = ProductionSchedule.new(production_schedule_params)
    @production_schedule.save
    respond_with(@production_schedule)
  end

  def update
    @production_schedule.update(production_schedule_params)
    respond_with(@production_schedule)
  end

  def destroy
    @production_schedule.destroy
    respond_with(@production_schedule)
  end

  private
    def set_production_schedule
      @production_schedule = ProductionSchedule.find(params[:id])
    end

    def production_schedule_params
      params.require(:production_schedule).permit(:task, :due_date, :order_id)
    end
    
    def search_params
      production_schedule_params.permit(:task, :due_date, :order_id)
    end
    
    def set_page_title
      @page_title = "生产计划管理" 
    end
end
